@(uidOpt: Option[String], userOpt: Option[User], createEvents: List[Event], events: List[Event])(implicit request: RequestHeader)
@import utils.RequestHelper

@headImg = @{
  userOpt.map(_.setting.headImg).getOrElse{
    uidOpt.map(_ => "/assets/images/head.png").getOrElse{
      RequestHelper.getHeadImg
    }
  }
}

@name = @{
  userOpt.map(_.setting.name).getOrElse{
    uidOpt.map(_ => "他").getOrElse{
      RequestHelper.getNameOpt.getOrElse("他")
    }
  }
}

@main("欢迎来到社区！") {
<div class="fly-home fly-panel" style="background-image: url();">
  <img src="@headImg">
  <h1>
    @name
    <i class="iconfont icon-nan"></i>
    <!-- <i class="iconfont icon-nv"></i> -->
    @if(userOpt.map(_.role).getOrElse("") == "admin"){
    <span style="color:#5FB878">(管理员)</span>
    }
    <!-- <span style="color:#c00;">（超级码农）</span>
    <span style="color:#5FB878;">（活雷锋）</span>
    <span>（该号已被封）</span> -->
  </h1>
  <p class="fly-home-info">
    <i class="iconfont icon-zuichun" title="飞吻"></i><span style="color: #FF7200;">@{userOpt.map(_.score).getOrElse(0)}飞吻</span>
    <i class="iconfont icon-shijian"></i><span>@{userOpt.map(u => utils.DateTimeUtil.toString(u.stat.createTime, "yyyy-MM-dd HH:mm")).getOrElse("刚刚")} 加入</span>
    <i class="iconfont icon-chengshi"></i><span>来自@{userOpt.map(_.ipLocation.map(_.city).getOrElse("中国")).getOrElse("中国")}</span>
  </p>
  <p class="fly-home-sign">@{userOpt.map(_.setting.introduction).getOrElse("")}</p>
</div>

<div class="layui-container">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md6 fly-home-jie">
      <div class="fly-panel">
        <h3 class="fly-panel-title">@name 最近的贡献</h3>
        <ul class="jie-row">
          @for(e <- createEvents){
          <li>
            <a href="/@{e.resType}/view?_id=@e.resId" class="jie-title">@e.resTitle</a>
            <i>@utils.DateTimeUtil.toPrettyString(e.createTime)</i>
            <em>@utils.AppUtil.prettyResource(e.resType)</em>
          </li>
          }
          @if(createEvents.isEmpty){
          <div class="fly-none" style="min-height: 50px; padding:30px 0; height:auto;"><span>没有做出任何贡献</span></div>
          }
        </ul>
      </div>
    </div>

    <div class="layui-col-md6 fly-home-da">
      <div class="fly-panel">
        <h3 class="fly-panel-title">@name 最近的动态</h3>
        <ul class="home-jieda">
          @for(e <- events){
          <li>
            <p>
              <span>@utils.DateTimeUtil.toPrettyString(e.createTime)</span>
              @utils.AppUtil.prettyAction(e.action)@utils.AppUtil.prettyResource(e.resType) <a href="/@{e.resType}/view?_id=@e.resId" target="_blank">@{e.resTitle}</a>
            </p>
          </li>
          }
          @if(events.isEmpty){
          <div class="fly-none" style="min-height: 50px; padding:30px 0; height:auto;"><span>没有任何动态</span></div>
          }
        </ul>
      </div>
    </div>
  </div>
</div>
}

<script>
layui.cache.page = 'user';
</script>
